﻿package org.openChart.sprite.util 
{
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import org.openChart.sprite.BaseSprite;
	
	/**
	 * ...
	 * @author Chongyuan Yang
	 */
	public class Helper 
	{
		private var repeatCount:uint = 100;
		private var target:BaseSprite;
		private var alpha_1:Number;
		private var alpha_2:Number;
		public function Helper(target:BaseSprite, alpha_1:Number = 0, alpha_2:Number = 1, time:Number = 5000) 
		{
			this.alpha_1 = alpha_1;
			this.alpha_2 = alpha_2;
			this.target = target;
			target.alpha = alpha_1;
			var timer:Timer = new Timer( time / 1000, repeatCount);
			timer.start();
			timer.addEventListener(TimerEvent.TIMER, onTick);
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
		}
		
		public function onTick( event:TimerEvent ):void
		{
			target.alpha += (alpha_2 - alpha_1) / repeatCount;
		}
		
		public function timerComplete( event:TimerEvent ):void
		{
			
		}
		
	}
	
}